<template>
  <div class="header">
    <div class="header-left">
      <div class="iconfont back-icon">&#xe65e;</div>
    </div>
    <div class="header-input">
      <span class="iconfont search-icon">&#xe631;</span>
    </div>
    <router-link to="/city">
      <div class="header-right">
          {{ city }}
        <span class="iconfont arrow-icon">&#xe866;</span>
      </div>
    </router-link>
  </div>
</template>

<script>
import {mapState} from 'vuex';
export default {
  name: "HomeHeader",
   // 将state中的city属性映射到computed中的city属性上
  computed:{
    ...mapState(['city'])
  }
};
</script>

<style lang="scss" scoped>
@import "~@/assets/style/varibles.scss";
@import "~@/assets/style/mixins.scss";
.header {
  height: 0.86rem;
  display: flex;
  background-color: $bgColor;
  color: #fff;
  line-height: 0.86rem;
  .header-left {
    width: 0.64rem;
    float: left;
    .back-icon {
      text-align: center;
      font-size: 0.4rem;
    }
  }
  .header-input {
    padding-left: 0.2rem;
    flex: 1;
    background-color: #fff;
    border-radius: 0.1rem;
    margin-top: 0.12rem;
    margin-left: 0.2rem;
    line-height: 0.64rem;
    height: 0.64rem;
    color: #ccc;
    .search-icon {
      text-align: center;
      font-size: 0.4rem;
      position: relative;
      top: 0.04rem;
    }
  }
  .header-right {
    min-width: 1.04rem;
    padding:0 .1rem;
    float: right;
    text-align: center;
    color: #fff;
    .arrow-icon {
      font-size: 0.24rem;
      margin-left: -0.04rem;
    }
  }
}
</style>
